import request from "@/utils/request";
import type { AxiosPromise } from "axios";


//商品分类列表
export function listCategories(queryParams:object){
    return request({
        url:"/mall-pms/api/v1/categories",
        method:"get",
        params:queryParams
    })
}

//商品分类级联器树形列表
export function getCategoryOptions(): AxiosPromise<OptionType[]> {
    return request({
        url: "/mall-pms/api/v1/categories/options",
        method: "get"
    })
}

//添加
export function addCategories (data:object){
    return request({
        url:"/mall-pms/api/v1/categories",
        method:"post",
        data:data
    })
}

//获取详情
export function getCategories (id:number){
    return request({
        url:"/mall-pms/api/v1/categories/"+id,
        method:"get"
    })
}

//修改
export function updateCategories (id:number,data:object){
    return request({
        url:"/mall-pms/api/v1/categories/"+id,
        method:"put",
        data:data 
    })
}

//删除
export function deleteCategories (ids:string){
    return request({
        url:"/mall-pms/api/v1/categories/"+ids,
        method:"delete"
    })
}

// 选择性修改商品分类
export function updateSelectiveCategories (id:number,data:object){
    return request({
        url:"/mall-pms/api/v1/categories/"+id,
        method:"patch",
        data:data
    })
}